package com.yft.dao.pos_information;

import com.yft.dao.base.BaseConstant;
import com.yft.dao.base.BaseDao;
import com.yft.entity.base.BaseEntityUtils;
import com.yft.entity.base.Order;
import com.yft.entity.base.Pager;
import com.yft.entity.posinformation.PosBusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;


@Service("posBusinessTypeDao")
public class PosBusinessTypeDao {
	
	@Autowired(required = true)
	@Qualifier(BaseConstant.DAO_NAME)
	private BaseDao dao;
	
	public Object addPosBusinessType(PosBusinessType posBusinessType) {
		return dao.addEntity(posBusinessType);
	}
	
	public PosBusinessType getPosBusinessType(Object posBusinessTypePK){
		return (PosBusinessType)dao.getEntity(PosBusinessType.class,(Serializable)posBusinessTypePK);
	}
	

	public boolean updateValues(PosBusinessType condition,String customStr){
		return dao.updateValues(condition, customStr);
	}
	
	@SuppressWarnings("unchecked")
	public List<PosBusinessType> getPosBusinessTypeList(PosBusinessType condition, Order order,Pager pager){
		return getList("",condition,order,pager);
	}	
	
	@SuppressWarnings("unchecked")
	private List getList(String hql,PosBusinessType condition,Order order,Pager pager){
		
		String q = hql+"from PosBusinessType c  where 1=1 ";
		q += makeCondition(condition);
		q += order!=null? order.toString():"";
		
		return dao.getListPager(q,condition,pager);
		
	}
	
	public String makeCondition(PosBusinessType condition){
		condition = condition==null? new PosBusinessType():condition;
		
		String q = "";
		q += BaseEntityUtils.makeBaseCondition(condition);
		
		return q;
	}
}
